package Demo3;

public class Computer {
    public void poweron(){
        System.out.println("电脑开机");
    }

    public void poweroff(){
        System.out.println("电脑关机");
    }

    public void useService(IUsb usb){
        usb.openDevice();
        if(usb instanceof Mouse){
            Mouse mouse =(Mouse)usb;
            mouse.click();
        }
        else if(usb instanceof KeyBoard){
            KeyBoard boead1=(KeyBoard)usb;
            boead1.input();
        }
        usb.closeDevice();
    }
}
